package com.xiaoyang.gatewayserver.config;


import org.springframework.cloud.gateway.route.RouteLocator;

import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @auther XiaoYang
 * @DATE 2023/5/6-16:09
 */
@Configuration
public class RouteConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                //如果输入localhost/guochuang 则会路由转发到 http://www.bilibili.com/guochuang
                .route("guochuang-id",r -> r.path("/guochuang").uri("http://www.bilibili.com"))
                .route("dance-id",r -> r.path("/v/dance").uri("http://www.bilibili.com"))
                .route("kuchiku-id",r -> r.path("/v/kuchiku").uri("http://www.bilibili.com"))
                .build();
    }

}
